home *** CD-ROM | disk | FTP | other *** search
- Path: thor.tu.hac.com!collins
- From: collins@thor.tu.hac.com (Ron Collins)
- Newsgroups: comp.lang.c
- Subject: Re: Do you have ever pass structures?
- Date: 22 Feb 1996 18:55:56 GMT
- Organization: Advanced Depot Systems
- Message-ID: <4gie7s$jim@hacgate2.hac.com>
- References: <4ge8mi$qjm@srvr1.engin.umich.edu> <312BE9C9.67A2284E@eden.com>
- NNTP-Posting-Host: thor.tu.hac.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Shane Sadler (nexus@eden.com) wrote:
-
- : As you know passing an entire structure to a function pushes that
- : structure onto the stack. By passing pointers, you avoid that sort of
- : overhead and your code is more efficient. When I'm writing what Mr.
- : Collins would call "disposable programs," I might just declare my
- ^^^^^^^
-
- Sounds like an intelligent, rational, good-looking chap.
-
- : structures globally just out of laziness and expediency, but I can't
- : think of a case in which I would pass the whole structure. So my answer
- : would be "no". Of course, someone else may have experience with passing
- : very small structures (one or two elements). There might be some
- : advantage in this, but a "REAL" advantage? I doubt it. Depends on what
- : you mean by "REAL," I guess...
-
- : -- Shane
-
-
- About the only use I can come up with for passing a large structure on the
- stack would be to interface to a routine written in another language.
- Exactly what that language would be, I haven't a clue. Outside of this,
- the pass-by-value mechanism for a large structure seems like one of those
- interesting little tidbits that is nice to know about, but rarely ever
- used.
-
- Anyone have any examples of using this, where it actually saved time or
- effort over passing a pointer?
-
-
- -- Collins --
-
- -----
- The views expressed here are mine alone.
-
- Ron Collins/Hughes Aircraft Company/M20,P20/Tucson Az 85706
- rcollins@thor.tu.hac.com collins@seagull.rtd.com
- ยก----
-